/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package transfer;

import java.security.MessageDigest;

/**
 *
 * @author MASTER
 */
public class Md5 {   
    
    //Devuelve el MD5 de lo que se desea enviar
    public static String generateMD5(String aEnviar){
        byte[] aEncriptar = aEnviar.getBytes();
        MessageDigest algorithm;
            try {
                algorithm = MessageDigest.getInstance("MD5");
                algorithm.reset();
                algorithm.update(aEncriptar);
                byte messageDigest[] = algorithm.digest();
                StringBuffer hexString = new StringBuffer();
                for (int i=0;i<messageDigest.length;i++) {
                    hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
                }
                return hexString.toString();
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
        return null;    
    }
    
}
